package com.example.spring.exercise.service.impl;

import com.example.spring.exercise.entity.UserEntity;
import com.example.spring.exercise.repository.UserRepository;
import com.example.spring.exercise.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author : zhayh
 * @date : 2021-4-28 20:26
 * @description :
 */

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserRepository userRepository;

    @Override
    public UserEntity updateUserHeader(String login, String headImage) {
        UserEntity userEntity = userRepository.findByLogin(login).orElse(null);
        if (userEntity != null) {
            userEntity.setHeadImage(headImage);
            return userRepository.save(userEntity);
        }
        return null;
    }
}
